<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>主控制台</title>
    <style>
        :root {
            --primary-color: #4361ee;
            --secondary-color: #3f37c9;
            --success-color: #4cc9f0;
            --danger-color: #f72585;
            --warning-color: #f8961e;
            --light-color: #f8f9fa;
            --dark-color: #212529;
            --border-radius: 12px;
            --box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
            --transition: all 0.3s ease;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
            color: var(--dark-color);
        }

        .container {
            max-width: 800px;
            margin: 40px auto;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: var(--border-radius);
            box-shadow: var(--box-shadow);
            overflow: hidden;
        }

        header {
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
            color: white;
            padding: 25px 30px;
            text-align: center;
        }

        h1 {
            font-size: 2rem;
            font-weight: 600;
            letter-spacing: 1px;
        }

        .content {
            padding: 30px;
        }

        .nav-links {
            margin-bottom: 30px;
        }

        .nav-links a {
            display: block;
            margin: 15px 0;
            padding: 16px 20px;
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
            color: white;
            text-decoration: none;
            border-radius: var(--border-radius);
            text-align: center;
            font-weight: 600;
            font-size: 1.1rem;
            transition: var(--transition);
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
            border: none;
            cursor: pointer;
        }

        .nav-links a:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
            background: linear-gradient(to right, var(--secondary-color), var(--primary-color));
        }

        .nav-links a:active {
            transform: translateY(-1px);
        }

        .stream-controls {
            margin-top: 30px;
        }

        .stream-controls button {
            display: block;
            width: 100%;
            padding: 16px 20px;
            margin: 15px 0;
            font-size: 1.1rem;
            font-weight: 600;
            border: none;
            border-radius: var(--border-radius);
            cursor: pointer;
            transition: var(--transition);
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        }

        .stream-controls button:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
        }

        .stream-controls button:active {
            transform: translateY(-1px);
        }

        .start-stream {
            background: linear-gradient(to right, #28a745, #218838);
            color: white;
        }

        .stop-stream {
            background: linear-gradient(to right, var(--danger-color), #b5179e);
            color: white;
        }

        @media (max-width: 768px) {
            .container {
                margin: 20px auto;
            }
            
            .content {
                padding: 20px;
            }
            
            h1 {
                font-size: 1.5rem;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>主控制台</h1>
        </header>
        
        <div class="content">
            <div class="nav-links">
                <a href="/sisu-login" target="_self">1. 登陆</a>
                <a href="/console" target="_self">2. 选择主机</a>
                <a href="/setting" target="_self">3. 设置</a>
            </div>
            
            <div class="stream-controls">
                <button class="start-stream" onclick="startStream()">开始串流</button>
                <button class="stop-stream" onclick="stopStream()">结束串流</button>
            </div>
        </div>
    </div>

    <script>
        function startStream() {
            fetch('/api/stream_start')
                .then(response => {
                    if (response.ok) {
                        alert('串流已开始');
                    } else {
                        alert('开始串流失败');
                    }
                })
                .catch(error => {
                    console.error('Error:', error);
                    alert('开始串流时发生错误');
                });
        }
        
        function stopStream() {
            fetch('/api/stream_stop')
                .then(response => {
                    if (response.ok) {
                        alert('串流已结束');
                    } else {
                        alert('结束串流失败');
                    }
                })
                .catch(error => {
                    console.error('Error:', error);
                    alert('结束串流时发生错误');
                });
        }
    </script>
</body>
</html>